package com.system.dao;

import com.am.base.BaseDao;
import com.system.uitls.CommonUtil;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

public class CostDefinitionDao extends BaseDao
{
  public Map<String, String> update(Map<String, Object> map)
  {
    String id = CommonUtil.nullToEmptyString(map.get("id"));
    String percentage = CommonUtil.nullToEmptyString(map.get("percentage"));
    String register_amount = CommonUtil.nullToEmptyString(map.get("register_amount"));
    String max_consume = CommonUtil.nullToEmptyString(map.get("max_consume"));
    String notes = CommonUtil.nullToEmptyString(map.get("notes"));
    Map result = new HashMap();
    String sql = "";
    try {
      sql = "update sys_cost_definition set percentage=?,register_amount=?,notes=?,max_consume=? where id=?";
      getSimpleJdbc().update(sql, new Object[] { percentage, register_amount, notes, max_consume, id });
      logger.info("CostDefinitionDao[update]-->sql:" + sql);
      result.put("type", "success");
      result.put("value", "修改成功");
    }
    catch (Exception ex) {
      logger.error("CostDefinitionDao[update]-->sql:" + sql + "\n" + ex.getMessage());
      result.put("type", "fail");
      result.put("value", "修改失败");
    }
    return result;
  }
}